Method: CommandMapper::Command#[]

Defined in:
lib/command_mapper/command.rb

#[](name) ⇒ Object

Gets the value of an option or an argument.

Parameters:

  • name (Symbol)

    The name of the option, argument, or subcommand.

Returns:

  • (Object)

    The value of the option, argument, or subcommand.

Raises:

  • (ArgumentError)

    The given name was not match any option or argument.


631
632
633
634
635
636
637
638
639
# File 'lib/command_mapper/command.rb', line 631

def [](name)
  name = name.to_s

  if respond_to?(name)
    send(name)
  else
    raise(ArgumentError,"#{self.class} does not define ##{name}")
  end
end